package com.mgface.framework.component;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.springframework.boot.context.embedded.Compression;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

@Configuration("SBDSystemConfiguration")
public class SBDSystemConfiguration {
	@Bean
	public EmbeddedServletContainerCustomizer containerCustomizer() {
		final Compression compression = new Compression();
		compression.setEnabled(true);
		Set<ErrorPage> set = new HashSet<>();
		set.add(new ErrorPage(HttpStatus.NOT_FOUND, "/404"));
		set.add(new ErrorPage(Exception.class, "/exception"));
		Set<ErrorPage> unmodifiableSet = Collections.unmodifiableSet(set);
		return e -> {
			//e.setSessionTimeout(30, TimeUnit.SECONDS);
			//e.setPort(8443);
			e.setCompression(compression);
			e.setErrorPages(unmodifiableSet);
		};
	}
}
